package com.xjx.service.Impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.xjx.dao.MemberDao;
import com.xjx.pojo.Member;
import com.xjx.service.MemberService;
import com.xjx.utils.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Version v1.0
 * @ClassName:
 * @Description:
 * @Author:xjx
 */
@Service(interfaceClass = MemberService.class)
@Transactional
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberDao memberDao;

    @Override
    public Member findByTelephone(String telephone) {
        return memberDao.findByTelephone(telephone);
    }

    @Override
    public void add(Member member) {
        String password = member.getPassword();
        //因为用户可能是自动注册的，所以密码存在为空的可能.所以判断密码不为空时要加密
        if (password!=null){
            String md5 = MD5Utils.md5(password);
            member.setPassword(md5);
        }
        memberDao.add(member);
    }
}
